<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>组件</title>
    <script src="./js/react.development.js"></script>
    <script src="./js/react-dom.development.js"></script>
    <script src="./js/babel.min.js"></script>
    <style>
      #header{
        height: 100px;
        background: #aef;
      }

      #main{
        height: 400px;
        background: rgb(61, 133, 151);
      }

      #footer{
        height: 100px;
        background: rgb(29, 83, 138);
      }
    </style>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/babel">

      //声明一个函数  函数名称『首字母一定要大写』
      function Header(){
        //返回虚拟 DOM 对象
        return <div id="header"></div>;
      }

      //main组件
      function Main(){
        return <div id="main"></div>;
      }

      function Footer(){
        return <div id="footer"></div>
      }

      //声明虚拟 DOM 对象
      // <Header>  渲染的时候, 会根据标签名自动找同名的『函数』, 调用该函数, 得到虚拟 DOM 对象
      function App(){
        return <div>
              <Header></Header>
              <Main />
              <Footer />
            </div>
      }
        
      //渲染
      ReactDOM.render(<App />, document.querySelector('#root'));
    </script>
  </body>
</html>
